<?php
  require_once('tpl/header.php');
?>
<?php 

	require_once("inc_admin.php");
	connect();

	$videoname=$_POST["videoname"];
    $videotype=$_POST["videotype"];
    $intro=$_POST["intro"];
    $address=$_POST["address"];
    //文件上传
	$arr=explode(".", $_FILES["pic"]["name"]);
	$suffix=$arr[count($arr)-1];
	$allowtype=array("jpg","jpeg","png","PNG","JPG","JPEG","Bmp","gif");
	if(!in_array($suffix,$allowtype))
	{
       //扩展名不在allowtype中
		// echo "文件类型不是图片类型";
		// exit;//php脚本退出结束
		die("文件类型不是图片类型，请重新选择");
	}
	else
	{
		echo "海报文件已上传成功";
		echo "<br>";
	}
	$filePath="../posters/";
	$randname=date("YmdHis").rand(100,999).".".$suffix;
	move_uploaded_file($_FILES["pic"]["tmp_name"],$filePath.$randname);
	//去管理员的adminid
	// var_dump($_SESSION);
	$uploadadmin=$_SESSION["aminid"];
	//sql语句
   $sql="insert into videos value(null,'$videoname','$videotype','$randname','$intro',now(),$uploadadmin,0,0,'$address')";
   $resule=mysql_query($sql);
   if ($resule==1) {
   echo "视频添加成功。3S后返回添加页可继续添加";
   header("refresh:3;url='videoadd.php'");
   }
   else
   {
   	echo "视频添加失败";
   }
 ?>

   


<?php
  require_once('tpl/footer.php');
?>